package com.wjy.rbac.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wjy.rbac.entity.UserRole;
import com.wjy.rbac.mapper.UserRoleMapper;
import com.wjy.rbac.service.IUserRoleService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author ybxxszl
 * @since 2019-04-12
 */
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements IUserRoleService {

    @Override
    public void insert(UserRole userRole) {
        save(userRole);
    }

    @Override
    public void update(UserRole userRole) {
        updateById(userRole);
    }

    @Override
    public void delete(String userRoleId) {
        removeById(userRoleId);
    }

    @Override
    public Map<String, Object> get(String userId) {
        Map<String, Object> map = new HashMap<String, Object>();
        UserRole userRole = getById(userId);
        map.put("userRole", userRole);
        return map;
    }

    @Override
    public List<UserRole> getByUserIdList(String userId) {
        Map<String, Object> columnMap = new HashMap<String, Object>();
        columnMap.put(UserRole.USER_ID, userId);
        List<UserRole> userRoleList = (List<UserRole>) listByMap(columnMap);
        return userRoleList;
    }

}
